package com.fuqi.android.zhongcai.base.view.adapter;

import android.content.Context;

import com.fuqi.android.zhongcai.R;
import com.fuqi.android.zhongcai.base.Constants;
import com.fuqi.android.zhongcai.business.shuig.OrderDict;
import com.fuqi.android.zhongcai.business.shuig.request.result.OrderListResult;
import com.fuqi.android.zhongcai.sql.Dic;
import com.fuqi.android.zhongcai.sql.dao.SQLDao;

import java.util.List;

/**
 * create by juner
 * @Date 2016-8-31
 */


public class OrderCustomerAdapter extends BaseRecyclerViewAdapter<OrderListResult>{
    Context context;

    public OrderCustomerAdapter(Context context,List<OrderListResult> datas) {
        super(datas);
        this.context = context;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.adapter_order_customer;
    }

    @Override
    protected void onBind(ViewHolder holder, int position,OrderListResult data) {

        holder.setTextView(R.id.tv_contact_name, data.getContactName());
        holder.setTextView(R.id.tv_contact_phone, data.getContactPhone());
            Dic dic = SQLDao.getInstance(context.getApplicationContext()).selectWithType(data.getInstallContent()+"");
            if(dic != null)
                holder.setTextView(R.id.tv_install, dic.getName());
            else
                holder.setTextView(R.id.tv_install, data.getInstallContent());
        {
            String status = data.getOrderStatus();
            String tempdate = data.getInstallDate();
            switch (status) {
                case OrderDict.StatusType.DDZT_DSZ:
                case OrderDict.StatusType.DDZT_BTG:
                case OrderDict.StatusType.DDZT_DCL:
                case OrderDict.StatusType.DDZT_KHWFLX:
                case OrderDict.StatusType.DDZT_BKAZ:
                    tempdate = data.getInstallDate();
                    break;
                default:
                    tempdate = data.getAppointmentDate() + " " + data.getAppointmentTime();
                    break;
            }
            holder.setTextView(R.id.tv_install_date, tempdate);
        }

        holder.setTextView(R.id.tv_install_address, data.getAddArea());

        switch (data.getOrderStatus()){

            case Constants.DAI_SHE_HE:
                holder.setTextView(R.id.tv_comment_status, "待审核");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_yellow));
                break;
            case Constants.BU_TONG_GUO:
                holder.setTextView(R.id.tv_comment_status, "不通过");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_red));
                break;
            case Constants.DAI_CHU_FA:
                holder.setTextView(R.id.tv_comment_status, "待出发");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_yellow));
                break;
            case Constants.DAI_AN_ZHUANG:
                holder.setTextView(R.id.tv_comment_status, "待安装");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_yellow));
                break;
            case Constants.DAI_CHU_LI_ORDER:
                holder.setTextView(R.id.tv_comment_status, "待处理");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_yellow));
                break;
            case Constants.AN_ZHUANG_ZHONG:
                holder.setTextView(R.id.tv_comment_status, "安装中");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_yellow));
                break;
            case Constants.BU_KE_AN_ZHUANG:
                holder.setTextView(R.id.tv_comment_status, "不可安装");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_red));
                break;
            case Constants.AN_ZHUANG_WAN_CHENG:
                holder.setTextView(R.id.tv_comment_status, "安装完成");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_green));
                break;
            case Constants.DAI_HUI_FANG:
                holder.setTextView(R.id.tv_comment_status, "待回访");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_green));
                break;
            case Constants.YI_HUI_FANG:
                holder.setTextView(R.id.tv_comment_status, "已回访");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_green));
                break;
            case Constants.YI_CHOU_CHA_ORDER:
                holder.setTextView(R.id.tv_comment_status, "已抽查");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_green));
                break;
            case Constants.YI_PING_LUN:
                holder.setTextView(R.id.tv_comment_status, "已评论");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_green));
                break;
            case Constants.KE_HU_NO_CONTACT:
                holder.setTextView(R.id.tv_comment_status, "客户不可联系");
                holder.setTextColor(R.id.tv_comment_status, context.getResources().getColor(R.color.main_red));
                break;


        }

    }
}
